<?php

include('../functions/db.php');

$naslov = mres(($_POST['naslov']));
$clanak = mres(($_POST['clanak']));
$username = mres(($_POST['username']));
$post_id = mres(($_POST['post_id']));
$category = mres(($_POST['category']));

if ($category == "Nova") {
    $category = mres(($_POST['new_category']));
}

if ($post_id == 0) { //is new post
    $p = insertNewMagazinClanak($naslov, $clanak, $username, $category);
} else { // existing post do update
    updateMagazinClanak($post_id, $naslov, $clanak, $category, $username);
    $p = $post_id;
}

header("Location: ../?page=magazin_single&p=$p");
?>
